//package org.jeecg.modules.zcgl.tencent.controller;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.jeecg.common.api.vo.Result;
//import org.jeecg.common.exception.JeecgBootException;
//import org.jeecg.common.system.query.QueryGenerator;
//import org.jeecg.common.system.util.JwtUtil;
//import org.jeecg.common.util.DateUtils;
//import org.jeecg.common.util.IPUtils;
//import org.jeecg.common.util.UUIDGenerator;
//import org.jeecg.modules.zcgl.entity.OrderDetails;
//import org.jeecg.modules.zcgl.entity.ReceivablesInfo;
//import org.jeecg.modules.zcgl.enums.AttentionPayStatusEnum;
//import org.jeecg.modules.zcgl.enums.PayStatusEnum;
//import org.jeecg.modules.zcgl.enums.PayTypeEnum;
//import org.jeecg.modules.zcgl.service.IOrderService;
//import org.jeecg.modules.zcgl.service.IReceivablesInfoService;
//import org.jeecg.modules.zcgl.tencent.config.CheckLogin;
//import org.jeecg.modules.zcgl.tencent.config.IWxPayConfig;
//import org.jeecg.modules.zcgl.tencent.entity.AttentionInfo;
//import org.jeecg.modules.zcgl.tencent.sdk.WXPay;
//import org.jeecg.modules.zcgl.tencent.sdk.WXPayUtil;
//import org.jeecg.modules.zcgl.tencent.service.IAttentionInfoService;
//import org.jeecg.modules.zcgl.tencent.service.ICustomerAttentionService;
//import org.jeecg.modules.zcgl.tencent.vo.WxPayResultVo;
//import org.jeecg.modules.zcgl.util.NoUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.math.BigDecimal;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
///**
// * @Description: 微信用户付款订单信息
// * @Author: jeecg-boot
// * @Date: 2020-07-13
// * @Version: V1.0
// */
//@Api(tags = "微信用户付款订单信息")
//@RestController
//@RequestMapping("/tencent/order")
//@Slf4j
//public class OrderController {
//    @Autowired
//    private IOrderService orderService;
//    @Autowired
//    private IOrderDetailsService orderDetailsService;
//
//
//    @Autowired
//    private IAttentionInfoService attentionInfoService;
//    @Autowired
//    private IReceivablesInfoService receivablesInfoService;
//    @Autowired
//    private ICustomerAttentionService customerAttentionService;
//    @Autowired
//    private IWxPayConfig iWxPayConfig;
//
//    @Value("${weChat.notify_url}")
//    private String notify_url;
//
////    @Value("${weChat.notice_date_no:3}")
////    private Integer noticeDateNo;
//
//
//    /**
//     * 分页列表查询
//     *
//     * @param receivablesInfo
//     * @param pageNo
//     * @param pageSize
//     * @param req
//     * @return
//     */
//    @CheckLogin
////    @AutoLog(value = "应收款项信息-分页列表查询")
//    @ApiOperation(value = "应收款项信息-分页列表查询", notes = "应收款项信息-分页列表查询")
//    @GetMapping(value = "/query")
//    public Result<?> query(ReceivablesInfo receivablesInfo,
//                           @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
//                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
//                           HttpServletRequest req) {
//        String attentionId = JwtUtil.getUserNameByToken(req);
//        Map<String, Object> param = new HashMap<>();
//        param.put("attentionId", attentionId);
//        param.put("payStartDate", DateUtils.formatDate(DateUtils.DATE_FORMAT));
//
//        receivablesInfo.setPayStatus(PayStatusEnum.UNPAID.getStatus());
//
//        List<String> customerIds = customerAttentionService.queryCustomerIdsByAttentionId(attentionId);
//        if (customerIds == null || customerIds.size() == 0) {
//            return Result.ok(new Page<>());
//        }
//        QueryWrapper<ReceivablesInfo> queryWrapper = QueryGenerator.initQueryWrapper(receivablesInfo, req.getParameterMap());
////        queryWrapper.lambda().sql
//        queryWrapper.and(i-> i.apply(QueryGenerator.getCustomerSql(customerIds)));
//        Page<ReceivablesInfo> page = new Page<ReceivablesInfo>(pageNo, pageSize);
//        IPage<ReceivablesInfo> pageList = receivablesInfoService.pageByWechat(page, queryWrapper, param);
//        return Result.ok(pageList);
//    }
//
//    /***
//     * 用户选择缴费信息
//     * @param ids
//     * @param req
//     * @return
//     */
//    @CheckLogin
//    @ApiOperation(value = "应收款项信息-付款提交", notes = "应收款项信息-付款提交")
//    @PostMapping(value = "/payBatchOrder")
//    public Result<?> payBatchOrder(@RequestParam(name = "ids", required = true) String ids,
//                                   HttpServletRequest req) {
//        String attentionId = JwtUtil.getUserNameByToken(req);
//
//        AttentionInfo attentionInfo = attentionInfoService.getById(attentionId);
//        if (attentionInfo == null) {
//            return Result.error("用户信息获取失败！");
//        }
//
//        //查询现在需要付款的信息有没有在订单详情中
//        LambdaQueryWrapper<OrderDetails> orderDetailsQueryWrapper = new LambdaQueryWrapper<>();
////        orderDetailsQueryWrapper.and(i -> i.eq(OrderDetails::getPayStatus, AttentionPayStatusEnum.PAYMENTS.getStatus()).
////                or().eq(OrderDetails::getPayStatus, AttentionPayStatusEnum.SUCCESSFUL.getStatus()));
//        orderDetailsQueryWrapper.eq(OrderDetails::getPayStatus, AttentionPayStatusEnum.SUCCESSFUL.getStatus());
//        orderDetailsQueryWrapper.in(OrderDetails::getReceivablesId, ids);
//        Integer totalNo = orderDetailsService.count(orderDetailsQueryWrapper);
//        if (totalNo != null && totalNo.intValue() != 0) {
//            return Result.error("有付款信息已经付款完成，请勿重复付款！");
//        }
//
//        //查询需要付款的付款信息列表
//        LambdaQueryWrapper<ReceivablesInfo> queryWrapper = new LambdaQueryWrapper<>();
//        queryWrapper.in(ReceivablesInfo::getId, ids.split(CommonConstant.DEFAULT_SEPARATOR));
//        List<ReceivablesInfo> receivablesInfoList = receivablesInfoService.list(queryWrapper);
//        List<OrderDetails> orderDetailsList = new ArrayList<>();
//        BigDecimal amountMoney = BigDecimal.ZERO;
//        for (ReceivablesInfo receivablesInfo : receivablesInfoList) {
//            //判断订单是否是待付款状态
//            if (receivablesInfo.getPayStatus() == null || receivablesInfo.getPayStatus().compareTo(PayStatusEnum.UNPAID.getStatus()) != 0) {
//                return Result.error("有订单不是待支付，请确认后支付！");
//            }
//
//            //计算订单总金额
//            amountMoney = amountMoney.add(receivablesInfo.getAmountMoney());
//
//            OrderDetails orderDetails = new OrderDetails();
//            orderDetails.setAmountMoney(receivablesInfo.getAmountMoney());
//            orderDetails.setLeaseContractId(receivablesInfo.getLeaseContractId());
//            orderDetails.setAssetId(receivablesInfo.getAssetId());
//            orderDetails.setAssetSubIds(receivablesInfo.getAssetSubIds());
//            orderDetails.setCustomerId(receivablesInfo.getCustomerId());
//            orderDetails.setEndTime(receivablesInfo.getEndTime());
//            orderDetails.setStartTime(receivablesInfo.getStartTime());
//            orderDetails.setReceivablesId(receivablesInfo.getId());
//            orderDetails.setPaymentInstructions(receivablesInfo.getPaymentInstructions());
//            orderDetails.setPayStatus(AttentionPayStatusEnum.UNPAID.getStatus());
//            orderDetails.setAttentionId(attentionId);
//            orderDetails.setPayType(PayTypeEnum.WECHAT_PAY.getStatus());
//
//            orderDetailsList.add(orderDetails);
//        }
//
//        Order order = new Order();
//        order.setAmountMoney(amountMoney);
//        order.setPayType(PayTypeEnum.WECHAT_PAY.getStatus());
//        order.setAttentionId(attentionId);
//        order.setOpenId(attentionInfo.getOpenid());
//        order.setCustomerId(orderDetailsList.get(0).getCustomerId());
//        order.setOrderNo(NoUtils.getOrderNo());
//        order.setPayStatus(AttentionPayStatusEnum.UNPAID.getStatus());
//        order.setIp(IPUtils.getIpAddr(req));
//        orderService.saveMain(order, orderDetailsList);
//        Map<String, String> map = this.wxPay(order.getId());
//        if (map != null) {
//            map.put("orderId", order.getId());
//            return Result.ok(map);
//        }
//        orderService.delPhysicalMain(order.getId());
//        return Result.error("支付下单失败，请稍后在试！");
//    }
//
//    /**
//     * 取消订单
//     * @param id
//     * @param type 1用户手动取消支付订单，2支付异常取消订单
//     * @return
//     */
//    @CheckLogin
////    @AutoLog(value = "微信用户付款订单信息-通过id删除")
//    @ApiOperation(value = "微信用户付款订单信息-取消订单", notes = "微信用户付款订单信息-取消订单")
//    @PostMapping(value = "/cancelOrder")
//    public Result<?> cancelOrder(@RequestParam(name = "id", required = true) String id,
//                                 @RequestParam(name = "type", required = true) Integer type) {
//        if (type == 1){
//            orderService.updatePayStatusById(id, AttentionPayStatusEnum.CANCELED.getStatus());
//        } else {
//            //支付异常
//            orderService.delPhysicalMain(id);
//        }
//        return Result.ok("订单取消成功!");
//    }
//
//    @CheckLogin
////    @AutoLog(value = "微信用户付款订单信息-通过id删除")
//    @ApiOperation(value = "微信用户付款订单信息-取消订单", notes = "微信用户付款订单信息-取消订单")
//    @GetMapping(value = "/queryOrderStatus")
//    public Result<?> queryOrderStatus(@RequestParam(name = "id", required = true) String id) {
//        Order order = orderService.getById(id);
//        if (order == null){
//            return Result.error("订单不存在");
//        }
//        int status = 0;
//        if (order.getPayStatus().intValue() == AttentionPayStatusEnum.SUCCESSFUL.getStatus()){
//            status = 1;
//        } else if (order.getPayStatus().intValue() == AttentionPayStatusEnum.FAILED.getStatus() ||
//                order.getPayStatus().intValue() == AttentionPayStatusEnum.CANCELED.getStatus()){
//            status = 2;
//        }
//        return Result.ok(status);
//    }
//
//    //    @GetMapping("/pay")
//    private Map<String, String> wxPay(String orderId) {
//        Order order = orderService.getById(orderId);
//        if (order == null) {
//            throw new JeecgBootException("订单不存在！");
//        }
//
//        // 发起微信支付
//        WXPay wxpay = null;
//        Map<String, String> result = new HashMap<>();
//        try {
//
//            // ******************************************
//            //
//            //  统一下单
//            //
//            // ******************************************
//            wxpay = new WXPay(iWxPayConfig); // *** 注入自己实现的微信配置类, 创建WXPay核心类, WXPay 包括统一下单接口
//
//            Map<String, String> data = new HashMap<String, String>();
//            data.put("body", "微信缴费");
//            data.put("out_trade_no", order.getOrderNo()); // 订单唯一编号, 不允许重复
////            data.put("total_fee", "101"); // 订单金额, 单位分
////            data.put("total_fee", "1"); // 订单金额, 单位分
//            data.put("total_fee", String.valueOf(order.getAmountMoney().multiply(new BigDecimal(100)).intValue())); // 订单金额, 单位分
//            data.put("spbill_create_ip", order.getIp()); // 下单ip
//            data.put("openid", order.getOpenId()); // 微信公众号统一标示openid
//            data.put("notify_url", notify_url); // 订单结果通知, 微信主动回调此接口
//            data.put("trade_type", "JSAPI"); // 固定填写
//
//            log.info("发起微信支付下单接口, request={}", data);
//            Map<String, String> response = wxpay.unifiedOrder(data); // 微信sdk集成方法, 统一下单接口unifiedOrder, 此处请求   MD5加密   加密方式
//            log.info("微信支付下单成功, 返回值 response={}", response);
//            String returnCode = response.get("return_code");
//            if (!"SUCCESS".equals(returnCode)) {
//                return null;
//            }
//            String resultCode = response.get("result_code");
//            if (!"SUCCESS".equals(resultCode)) {
//                return null;
//            }
//            String prepay_id = response.get("prepay_id");
//            if (prepay_id == null) {
//                return null;
//            }
//
//            // ******************************************
//            //
//            //  前端调起微信支付必要参数
//            //
//            // ******************************************
//            String packages = "prepay_id=" + prepay_id;
//            Map<String, String> wxPayMap = new HashMap<String, String>();
//            wxPayMap.put("appId", iWxPayConfig.getAppID());
//            wxPayMap.put("timeStamp", String.valueOf(System.currentTimeMillis()));
//            wxPayMap.put("nonceStr", UUIDGenerator.generate());
//            wxPayMap.put("package", packages);
//            wxPayMap.put("signType", "MD5");
//            // 加密串中包括 appId timeStamp nonceStr package signType 5个参数, 通过sdk WXPayUtil类加密, 注意, 此处使用  MD5加密  方式
//            String sign = WXPayUtil.generateSignature(wxPayMap, iWxPayConfig.getKey(), wxpay.getSignType());
//
//            // ******************************************
//            //
//            //  返回给前端调起微信支付的必要参数
//            //
//            // ******************************************
//            result.put("prepay_id", prepay_id);
//            result.put("sign", sign);
//            result.putAll(wxPayMap);
//            orderService.updatePayStatusById(order.getId(), AttentionPayStatusEnum.PAYMENTS.getStatus());
//            return result;
//        } catch (Exception e) {
//            log.error(e.getMessage());
//        }
//
//        return null;
//    }
//
//
//    @RequestMapping(value = "/wxPayCallback", method = RequestMethod.POST)
//    public String payCallback(HttpServletRequest request, HttpServletResponse response) {
//        log.info("进入微信支付异步通知");
//        String resXml = "";
//        try {
//            //
//            InputStream is = request.getInputStream();
//            //将InputStream转换成String
//            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
//            StringBuilder sb = new StringBuilder();
//            String line = null;
//            try {
//                while ((line = reader.readLine()) != null) {
//                    sb.append(line + "\n");
//                }
//            } catch (IOException e) {
//                e.printStackTrace();
//            } finally {
//                try {
//                    is.close();
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//            resXml = sb.toString();
//            log.info("微信支付异步通知请求包: {}", resXml);
//            return this.payBack(resXml);
//        } catch (Exception e) {
//            log.error("微信支付回调通知失败", e);
//            String result = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
//            return result;
//        }
//    }
//
//    private String payBack(String notifyData) {
//        log.info("payBack() start, notifyData={}", notifyData);
//        String xmlBack = "";
//        Map<String, String> notifyMap = null;
//        try {
//            WXPay wxpay = new WXPay(iWxPayConfig);
//
//            notifyMap = WXPayUtil.xmlToMap(notifyData);         // 转换成map
//            if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {
//				WxPayResultVo wxPayResultVo = new WxPayResultVo();
//				org.apache.commons.beanutils.BeanUtils.populate(wxPayResultVo, notifyMap);
//                // 签名正确
//                // 进行处理。
//                // 注意特殊情况：订单已经退款，但收到了支付结果成功的通知，不应把商户侧订单状态从退款改成支付成功
//
//                if (wxPayResultVo.getOut_trade_no() == null) {
//                    log.info("微信支付回调失败订单号: {}", notifyMap);
//                    xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
//                    return xmlBack;
//                }
//
//
//                // 业务逻辑处理 ****************************
//                log.info("微信支付回调成功订单号: {}", notifyMap);
//
//                orderService.updateWxPay(wxPayResultVo);
//                xmlBack = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>" + "<return_msg><![CDATA[SUCCESS]]></return_msg>" + "</xml> ";
//                return xmlBack;
//            } else {
//                log.error("微信支付回调通知签名错误");
//                xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
//                return xmlBack;
//            }
//        } catch (Exception e) {
//            log.error("微信支付回调通知失败", e);
//            xmlBack = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> ";
//        }
//        return xmlBack;
//    }
//
////    /**
////     * 分页列表查询
////     *
////     * @param order
////     * @param pageNo
////     * @param pageSize
////     * @param req
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单信息-分页列表查询")
////    @ApiOperation(value = "微信用户付款订单信息-分页列表查询", notes = "微信用户付款订单信息-分页列表查询")
////    @GetMapping(value = "/list")
////    public Result<?> queryPageList(Order order,
////                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
////                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
////                                   HttpServletRequest req) {
////        QueryWrapper<Order> queryWrapper = QueryGenerator.initQueryWrapper(order, req.getParameterMap());
////        Page<Order> page = new Page<Order>(pageNo, pageSize);
////        IPage<Order> pageList = orderService.page(page, queryWrapper);
////        return Result.ok(pageList);
////    }
////
////    /**
////     * 添加
////     *
////     * @param orderPage
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单信息-添加")
////    @ApiOperation(value = "微信用户付款订单信息-添加", notes = "微信用户付款订单信息-添加")
////    @PostMapping(value = "/add")
////    public Result<?> add(@RequestBody OrderPage orderPage) {
////        Order order = new Order();
////        BeanUtils.copyProperties(orderPage, order);
////        orderService.saveMain(order, orderPage.getOrderDetailsList());
////        return Result.ok("添加成功！");
////    }
////
////    /**
////     * 编辑
////     *
////     * @param orderPage
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单信息-编辑")
////    @ApiOperation(value = "微信用户付款订单信息-编辑", notes = "微信用户付款订单信息-编辑")
////    @PutMapping(value = "/edit")
////    public Result<?> edit(@RequestBody OrderPage orderPage) {
////        Order order = new Order();
////        BeanUtils.copyProperties(orderPage, order);
////        Order orderEntity = orderService.getById(order.getId());
////        if (orderEntity == null) {
////            return Result.error("未找到对应数据");
////        }
////        orderService.updateMain(order, orderPage.getOrderDetailsList());
////        return Result.ok("编辑成功!");
////    }
////
////    /**
////     * 通过id删除
////     *
////     * @param id
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单信息-通过id删除")
////    @ApiOperation(value = "微信用户付款订单信息-通过id删除", notes = "微信用户付款订单信息-通过id删除")
////    @DeleteMapping(value = "/delete")
////    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
////        orderService.delMain(id);
////        return Result.ok("删除成功!");
////    }
////
////    /**
////     * 批量删除
////     *
////     * @param ids
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单信息-批量删除")
////    @ApiOperation(value = "微信用户付款订单信息-批量删除", notes = "微信用户付款订单信息-批量删除")
////    @DeleteMapping(value = "/deleteBatch")
////    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
////        this.orderService.delBatchMain(Arrays.asList(ids.split(CommonConstant.DEFAULT_SEPARATOR)));
////        return Result.ok("批量删除成功！");
////    }
////
////    /**
////     * 通过id查询
////     *
////     * @param id
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单信息-通过id查询")
////    @ApiOperation(value = "微信用户付款订单信息-通过id查询", notes = "微信用户付款订单信息-通过id查询")
////    @GetMapping(value = "/queryById")
////    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
////        Order order = orderService.getById(id);
////        if (order == null) {
////            return Result.error("未找到对应数据");
////        }
////        return Result.ok(order);
////
////    }
////
////    /**
////     * 通过id查询
////     *
////     * @param id
////     * @return
////     */
////    @AutoLog(value = "微信用户付款订单详情信息通过主表ID查询")
////    @ApiOperation(value = "微信用户付款订单详情信息主表ID查询", notes = "微信用户付款订单详情信息-通主表ID查询")
////    @GetMapping(value = "/queryOrderDetailsByMainId")
////    public Result<?> queryOrderDetailsListByMainId(@RequestParam(name = "id", required = true) String id) {
////        List<OrderDetails> orderDetailsList = orderDetailsService.selectByMainId(id);
////        return Result.ok(orderDetailsList);
////    }
////
////    /**
////     * 导出excel
////     *
////     * @param request
////     * @param order
////     */
////    @RequestMapping(value = "/exportXls")
////    public ModelAndView exportXls(HttpServletRequest request, Order order) {
////        // Step.1 组装查询条件查询数据
////        QueryWrapper<Order> queryWrapper = QueryGenerator.initQueryWrapper(order, request.getParameterMap());
////        LoginUser sysUser = JwtUtil.getLoginUser();
////
////        //Step.2 获取导出数据
////        List<Order> queryList = orderService.list(queryWrapper);
////        // 过滤选中数据
////        String selections = request.getParameter("selections");
////        List<Order> orderList = new ArrayList<Order>();
////        if (oConvertUtils.isEmpty(selections)) {
////            orderList = queryList;
////        } else {
////            List<String> selectionList = Arrays.asList(selections.split(CommonConstant.DEFAULT_SEPARATOR));
////            orderList = queryList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
////        }
////
////        // Step.3 组装pageList
////        List<OrderPage> pageList = new ArrayList<OrderPage>();
////        for (Order main : orderList) {
////            OrderPage vo = new OrderPage();
////            BeanUtils.copyProperties(main, vo);
////            List<OrderDetails> orderDetailsList = orderDetailsService.selectByMainId(main.getId());
////            vo.setOrderDetailsList(orderDetailsList);
////            pageList.add(vo);
////        }
////
////        // Step.4 AutoPoi 导出Excel
////        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
////        mv.addObject(NormalExcelConstants.FILE_NAME, "微信用户付款订单信息列表");
////        mv.addObject(NormalExcelConstants.CLASS, OrderPage.class);
////        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("微信用户付款订单信息数据", "导出人:" + sysUser.getRealname(), "微信用户付款订单信息"));
////        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
////        return mv;
////    }
////
////    /**
////     * 通过excel导入数据
////     *
////     * @param request
////     * @param response
////     * @return
////     */
////    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
////    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
////        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
////        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
////        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
////            MultipartFile file = entity.getValue();// 获取上传文件对象
////            ImportParams params = new ImportParams();
////            params.setTitleRows(2);
////            params.setHeadRows(1);
////            params.setNeedSave(true);
////            try {
////                List<OrderPage> list = ExcelImportUtil.importExcel(file.getInputStream(), OrderPage.class, params);
////                for (OrderPage page : list) {
////                    Order po = new Order();
////                    BeanUtils.copyProperties(page, po);
////                    orderService.saveMain(po, page.getOrderDetailsList());
////                }
////                return Result.ok("文件导入成功！数据行数:" + list.size());
////            } catch (Exception e) {
////                log.error(e.getMessage(), e);
////                return Result.error("文件导入失败:" + e.getMessage());
////            } finally {
////                try {
////                    file.getInputStream().close();
////                } catch (IOException e) {
////                    e.printStackTrace();
////                }
////            }
////        }
////        return Result.ok("文件导入失败！");
////    }
//
//}
